package work803.work1;

import java.util.Objects;

public class Student {
  private int id;//学号
  private int age;//年龄
  private String name;//姓名
  private String idCard;//身份证

  public Student() {
  }

  public Student(int id, int age, String name, String idCard) {
    this.id = id;
    this.age = age;
    this.name = name;
    this.idCard = idCard;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getIdCard() {
    return idCard;
  }

  public void setIdCard(String idCard) {
    this.idCard = idCard;
  }

  @Override
  public boolean equals(Object o) {
//    System.out.println("重写的equals.....");
    if (this == o) {
      return true;
    }
    if (!(o instanceof Student)) {
      return false;
    }
    Student student = (Student) o;
    return getId() == student.getId();
  }

  @Override
  public int hashCode() {
    return Objects.hash(getId());
  }

  @Override
  public String toString() {
    return "学号：" + id +
      ", 姓名：" + name +
      ", 年龄：" + age +
      ", 身份证：" + idCard ;
  }

}
